<html>
<head>
<title>Title Faker - Options</title>
<style>
body {
  font-family:helvetica, arial, sans-serif;
  font-size:80%;
  margin:10px;
}

#header {
  padding-bottom:1.5em;
  padding-top:1.5em;
}

#header h1 {
  font-size: 156%;
  display:inline;
  padding-bottom:43px;
  padding-left:75px;
  padding-top:40px;
  background:url(icon128.png) no-repeat;
  background-size:67px;
  background-position:1px 18px;
}

.section-header {
  background:#ebeff9;
  border-top:1px solid #b5c7de;
  font-size:99%;
  padding:3px 0 2px 5px;
  font-weight:bold;
  margin-bottom:1em;
  margin-top:4em;
}

.section-header.first {
  margin-top:1em;
}

#custom-title {
  width:300px;
  margin-left:2px;
}

#footer {
  margin-top:4em;
}
</style>
</head>
<body>

<div id="header"><h1>Title Faker Options</h1></div>

<div class="section-header first">Custom title and favicon</div>
<p>set fake title<p><input type="text" id="fake-title" oninput="markDirty()">
    <em>(default Google)</em>
<p>set fake favicon<p><input type="text" id="fake-favicon" oninput="markDirty()">
    <em>(default Google's favicon: http://www.google.com/favicon.ico)</em>

<div id="footer">
  <button id="save-button" style="font-weight:bold" onclick="save()">Save</button>
  <button onclick="init()">Cancel</button>
</div>

<script>
var customTitleTextbox;
var saveButton;

init();

function init() {
  customTitleTextbox = document.getElementById("fake-title");
  customFavIconTextbox = document.getElementById("fake-favicon");
  saveButton = document.getElementById("save-button");

  customTitleTextbox.value = localStorage.customTitle || "";
  customFavIconTextbox.value = localStorage.customFavicon || "";
  markClean();
}

function save() {
  localStorage.customTitle = customTitleTextbox.value;
  localStorage.customFavicon = customFavIconTextbox.value;
  markClean();

  //chrome.extension.getBackgroundPage().init();
}

function markDirty() {
  saveButton.disabled = false;
}

function markClean() {
  saveButton.disabled = true;
}
</script>
</body>
</html>
